import 'package:delightful_toast/delight_toast.dart';
import 'package:delightful_toast/toast/components/toast_card.dart';
import 'package:delightful_toast/toast/utils/enums.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';

/// Toast提示工具类
class KudoToast {
  /// 显示成功提示
  static void showSuccessToast(BuildContext context, String message) {
    DelightToastBar(
      autoDismiss: true,
      position: DelightSnackbarPosition.top,
      builder:
          (context) => ToastCard(
            leading: Icon(
              Icons.check_circle,
            ).iconColor(Colors.green.shade600).iconSize(24.w),
            title: Text(message)
                .fontSize(14.sp)
                .textColor(Colors.green.shade800)
                .fontWeight(FontWeight.w500),
            color: Colors.green.shade50,
            shadowColor: Colors.green.shade200,
          ),
    ).show(context);
  }

  /// 显示失败提示
  static void showErrorToast(BuildContext context, String message) {
    DelightToastBar(
      autoDismiss: true,
      position: DelightSnackbarPosition.top,
      builder:
          (context) => ToastCard(
            leading: Icon(
              Icons.error,
            ).iconColor(Colors.red.shade600).iconSize(24.w),
            title: Text(message)
                .fontSize(14.sp)
                .textColor(Colors.red.shade800)
                .fontWeight(FontWeight.w500),
            color: Colors.red.shade50,
            shadowColor: Colors.red.shade200,
          ),
    ).show(context);
  }

  /// 显示警告提示
  static void showWarningToast(BuildContext context, String message) {
    DelightToastBar(
      autoDismiss: true,
      position: DelightSnackbarPosition.top,
      builder:
          (context) => ToastCard(
            leading: Icon(
              Icons.warning,
            ).iconColor(Colors.orange.shade600).iconSize(24.w),
            title: Text(message)
                .fontSize(14.sp)
                .textColor(Colors.orange.shade800)
                .fontWeight(FontWeight.w500),
            color: Colors.orange.shade50,
            shadowColor: Colors.orange.shade200,
          ),
    ).show(context);
  }

  /// 显示普通信息提示
  static void showInfoToast(BuildContext context, String message) {
    DelightToastBar(
      autoDismiss: true,
      position: DelightSnackbarPosition.top,
      builder:
          (context) => ToastCard(
            leading: Icon(
              Icons.info,
            ).iconColor(Colors.blue.shade600).iconSize(24.w),
            title: Text(message)
                .fontSize(14.sp)
                .textColor(Colors.blue.shade800)
                .fontWeight(FontWeight.w500),
            color: Colors.blue.shade50,
            shadowColor: Colors.blue.shade200,
          ),
    ).show(context);
  }

  /// 显示自定义提示
  static void showCustomToast(
    BuildContext context, {
    required String message,
    required IconData icon,
    required Color iconColor,
    required Color textColor,
    required Color backgroundColor,
    required Color shadowColor,
    DelightSnackbarPosition position = DelightSnackbarPosition.top,
    bool autoDismiss = true,
  }) {
    DelightToastBar(
      autoDismiss: autoDismiss,
      position: position,
      builder:
          (context) => ToastCard(
            leading: Icon(icon).iconColor(iconColor).iconSize(24.w),
            title: Text(
              message,
            ).fontSize(14.sp).textColor(textColor).fontWeight(FontWeight.w500),
            color: backgroundColor,
            shadowColor: shadowColor,
          ),
    ).show(context);
  }
}
